
<template>
  <el-button
    :size="size"
    :type="type"
    :disabled="disabled"
    v-if="isShow"
  >
  <slot>{{label}}</slot>
  </el-button>
</template>

<script>
export default {
  name: "Perm",
  props: {
    label: {
      type: String,
      default: "Button",
    },
    size: {
      // 按钮尺寸
      type: String,
      default: "medium",
    },
    type: {
      // 按钮类型
      type: String,
      default: "primary",
    },
    disabled:{
      type: Boolean,
      default: false,
    },
    level: {
      // 按钮权限标识，外部使用者传入
      type: Array,
      default:function(){
        return []
      }
    },
  },
  data() {
     return {
      isShow:true
     }
  },
  methods: {
    verify(){
      let userInfo = {}
			if(localStorage.getItem('userInfo')){
				userInfo = JSON.parse(localStorage.getItem('userInfo'))
			}
			if(!this.level.includes(userInfo.userLevel)){
          this.isShow = false
      }
    }
  },
  mounted() {
    this.verify()
  },
};
</script>
